import { createSlice } from '@reduxjs/toolkit'

const successSlice = createSlice({
  name: 'success',
  initialState: {
    shareOrEdit: false,
    mdContent: '',
    codeContent: '',
    successLanguage: '',
    theme: '',
    codeUrl: '',
    copyCode: '',
    focusLanguage: ''
  },
  reducers: {
    setShareOrEdit(state, action) {
      state.shareOrEdit = action.payload
    },
    setMdContent(state, action) {
      state.mdContent = action.payload
    },
    setCodeContent(state, action) {
      state.codeContent = action.payload
    },
    setSucessLanguage(state, action) {
      state.successLanguage = action.payload
    },
    setTheme(state, action) {
      state.theme = action.payload
    },
    setCodeUrl(state, action) {
      state.codeUrl = action.payload
    },
    setCopyCode(state, action) {
      state.copyCode = action.payload
    },
    setFocusLanguage(state, action) {
      state.focusLanguage = action.payload
    },
    resetStateSuc(state) {
      state.shareOrEdit = false
      state.mdContent = ''
      state.codeContent = ''
      state.successLanguage = ''
      state.theme = ''
      state.codeUrl = ''
      state.copyCode = ''
      state.focusLanguage = ''
    }
  }
})

export const {
  setShareOrEdit,
  setMdContent,
  setCodeContent,
  setSucessLanguage,
  setCodeUrl,
  setTheme,
  setCopyCode,
  setFocusLanguage,
  resetStateSuc
} = successSlice.actions

export default successSlice.reducer
